# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-octokit
pkgver=6.1.1
pkgrel=1
pkgdesc='Simple wrapper for the GitHub API'
arch=(any)
url='https://github.com/octokit/octokit.rb'
license=(MIT)
depends=(ruby-faraday ruby-sawyer)
makedepends=(ruby-rake)
checkdepends=(ruby-awesome_print ruby-yard ruby-rexml ruby-jwt ruby-mime-types ruby-multi_json
              ruby-netrc ruby-rb-fsevent ruby-rbnacl ruby-rspec ruby-simplecov ruby-vcr ruby-webmock
              ruby-pry-byebug ruby-redcarpet ruby-rss)
options=(!emptydirs)
source=(https://github.com/octokit/octokit.rb/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('2b027e74d91bf177b8d3c23882b5074a19cf0757d63f071e03e391b386443c20')

build() {
  local _gemdir="$(gem env gemdir)"
  cd octokit.rb-$pkgver
  gem build octokit.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    octokit-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd octokit.rb-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rake
}

package() {
  cd octokit.rb-$pkgver
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE.md -t "$pkgdir"/usr/share/licenses/$pkgname/
}
